<?php
$cs = Yii::app()->getClientScript();
$cs->registerCssFile(Yii::app()->request->baseUrl.'/css/jquery-ui.css');
$cs->registerCssFile(Yii::app()->request->baseUrl.'/css/fileuploader.css');
$cs->registerCoreScript('jquery');
$cs->registerCoreScript('jquery.ui');
$cs->registerScriptFile(Yii::app()->request->baseUrl.'/js/fileuploader.js');
$cs->registerScriptFile(Yii::app()->request->baseUrl.'/js/ckeditor/ckeditor.js');
$cs->registerScriptFile(Yii::app()->request->baseUrl.'/js/jquery-ui-timepicker-addon.js');

        $cs->registerScript('file-uploader-js',
	            'function onUploadComplete (id, fileName, responseJSON){
	                if (responseJSON.success)
	                {
	                    document.getElementById("Partner_image").value = responseJSON.imgurl;
	                }
	            }
				
	            $(document).ready(function(){
	            
	                var uploader = new qq.FileUploader({
	                    element: document.getElementById("file-uploader"),
	                    action: "'.$this->createUrl('fileUpload/index').'",
	                    allowedExtensions: ["jpg", "jpeg", "png", "gif"],
	                    params: { sizeLimit: "500K" },
	                    onComplete: onUploadComplete
	                });
	            });',
	        CClientScript::POS_END
	        );

?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'partner-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'pid'); ?>
		<?php echo $form->dropDownList($model,'pid', $pid); ?>
		<a href="<?php echo $this->createUrl('partnerCategory/admin'); ?>">Create Category</a>
		<?php echo $form->error($model,'pid'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'title'); ?>
		<?php echo $form->textField($model,'title',array('size'=>50,'maxlength'=>50)); ?>
		<?php echo $form->error($model,'title'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'image'); ?>
		<?php echo $form->textField($model,'image',array('size'=>50,'maxlength'=>50)); ?>
		<div id="file-uploader">
		 	<noscript>
				<p>Please enable JavaScript to use file uploader.</p>
			</noscript>
		</div>	
		<?php echo $form->error($model,'image'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'url'); ?>
		<?php echo $form->textField($model,'url',array('size'=>50,'maxlength'=>50)); ?>
		<?php echo $form->error($model,'url'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'desc'); ?>
		<?php echo $form->textField($model,'desc',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'desc'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'status'); ?>
		<?php echo $form->dropDownList($model,'status', array('N' => Yii::t('core_msg', 'Hide'), 'Y' => Yii::t('core_msg', 'Show'))); ?>
		<?php echo $form->error($model,'status'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->
